package com.example.springboot.controller;

import com.example.springboot.entity.SysMenu;
import com.example.springboot.entity.SysRole;
import com.example.springboot.entity.SysUser;
import com.example.springboot.service.SysMenuService;
import com.example.springboot.service.SysRoleService;
import com.example.springboot.service.SysUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * 页面 表控制层
 *
 * @author makejava
 * @since 2021-09-12 23::13:47
 */
@Controller
@RequestMapping("URMS")
public class ViewController {

	/**
	 * 服务对象
	 */
	@Resource
	private SysUserService sysUserService;
	@Resource
	private SysMenuService sysMenuService;
	@Resource
	private SysRoleService sysRoleService;

	/**
	 * 转到主界面页面
	 */
	@RequestMapping(value = "index")
	public String index() {
		return "URMS/index_home/index";
	}

	/**
	 * 转到登录页面
	 */
	@RequestMapping(value = "login")
	public String login() {
		return "URMS/login/login";
	}

	/**
	 * 转到登录页面
	 */
	@RequestMapping(value = "loginOut")
	public String loginOut() {
		return "URMS/login/login";
	}

	/**
	 * 转到登录页面
	 */
	@RequestMapping(value = "login_failure")
	public String login_failure() {
		return "URMS/login/login_failure";
	}

	/**
	 * 转到user-setting页面
	 */
	@RequestMapping(value = "sysUser/userSetting")
	public String userSetting() {
		return "URMS/sysUser/user-setting";
	}

	/**
	 * 转到user-password页面
	 */
	@RequestMapping(value = "sysUser/userPassword")
	public String userPassword() {
		return "URMS/sysUser/user-password";
	}

	/**
	 * 转到table页面
	 */
	@RequestMapping(value = "sysUser/table")
	public String userTable() {
		return "URMS/sysUser/table";
	}

	/**
	 * 转到addUser页面
	 */
	@RequestMapping(value = "sysUser/add")
	public String addUser() {
		return "URMS/sysUser/add";
	}

	/**
	 * 转到formStep页面
	 */
	@RequestMapping(value = "sysUser/formStep")
	public String formStep() {
		return "URMS/page/form-step";
	}

	/**
	 * 转到edit页面
	 */
	@RequestMapping(value = "sysUser/edit")
	public ModelAndView edit(Long id) {
		SysUser sysUser = this.sysUserService.queryById(id);
		ModelAndView modelAndView = new ModelAndView("URMS/sysUser/edit");
		modelAndView.addObject("editUser", sysUser);
		return modelAndView;
	}

	/**
	 * 转到error404页面
	 */
	@RequestMapping(value = "/error404")
	public String error404() {
		return "URMS/error/404";
	}

	/**
	 * 转到setting页面
	 */
	@RequestMapping(value = "setting")
	public String setting() {
		return "URMS/page/setting";
	}

	/**
	 * 转到menu页面
	 */
	@RequestMapping(value = "sysMenu/menu")
	public String menu() {
		return "URMS/sysMenu/menu";
	}

	/**
	 * 转到addMenu页面
	 */
	@RequestMapping(value = "sysMenu/add")
	public String addMenu() {
		return "URMS/sysMenu/add";
	}

	/**
	 * 转到addMenu页面
	 */
	@RequestMapping(value = "sysMenu/edit")
	public ModelAndView editMenu(Long id) {
		SysMenu sysMenu = this.sysMenuService.queryById(id);
		ModelAndView modelAndView = new ModelAndView("URMS/sysMenu/edit");
		modelAndView.addObject("editMenu", sysMenu);
		return modelAndView;
	}


	/**
	 * 转到table页面
	 */
	@RequestMapping(value = "sysRole/table")
	public String roleTable() {
		return "URMS/sysRole/table";
	}

	/**
	 * 转到addMenu页面
	 */
	@RequestMapping(value = "sysRole/add")
	public String addRole() {
		return "URMS/sysRole/add";
	}


	/**
	 * 转到addMenu页面
	 */
	@RequestMapping(value = "sysRole/edit")
	public ModelAndView editRole(Long id) {
		SysRole sysRole = this.sysRoleService.queryById(id);
		ModelAndView modelAndView = new ModelAndView("URMS/sysRole/edit");
		modelAndView.addObject("editRole", sysRole);
		return modelAndView;
	}

	/**
	 * 转到addMenu页面
	 */
	@RequestMapping(value = "sysRole/addPermissions")
	public ModelAndView addPermissions(Long id) {
		SysRole sysRole = this.sysRoleService.queryById(id);
		ModelAndView modelAndView = new ModelAndView("URMS/sysRole/addPermissions");
		modelAndView.addObject("addRole", sysRole);
		return modelAndView;
	}


}
